<?
class KasperskyAV extends AV {
    var $cmd='/usr/bin/sudo /opt/kaspersky/kes4lwks/bin/kes4lwks-control';
    var $file_stats='/tmp/garbirus_stats';

    function AV (){
        parent::__construct();
    }

    function setEngine(){
        //
        // sets AV description+version in '$this->engine'
        //

        $this->engine='Kaspersky Endpoint Security 8 for Linux';
    }

    function startAnalyzer($path){
        #$this->destroyAnalyzer();
        # Create task
        $result=exec($this->cmd." -C garbirus --use-task-type ODS");
        #echo "\nTarea creada: ".$result;
        # Change path
        $result=exec($this->cmd." --set-settings garbirus ScanScope:AreaPath.Path=".$path." -N");
        #echo "\nTarea modificada: ".$result;
        # Start task
        $result=exec($this->cmd." --start-task garbirus -N");
        #echo "\nTarea iniciada: ".$result;
        return "Analyze started with ".$this->engine;
    }

    function isRunning(){
        $status=exec($this->cmd." --get-task-state garbirus -N|grep -qs Stopped && echo $?");
        if ($status == "0"){
            return false;
        } else {
            return true;
        }

    }

    function printStats(){
        #$stats="0 infected files (scanned by ".$this->engine.")";
        $stats=exec($this->cmd." --get-stat ODS --task-id garbirus -N > ".$this->file_stats);
        $stats=file($this->file_stats, FILE_SKIP_EMPTY_LINES);
        $this->destroyAnalyzer();
        return $stats;
    }

    function destroyAnalyzer(){
        // Delete task
        $result=exec($this->cmd." -D garbirus -N");
    }
}
?>
